fix errors handling optional Waypoint fields. (#948)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Fri, 6 Jan 2023 14:03:26 +0000 (07:03 -0700)
committerGitHub <noreply@github.com>
Fri, 6 Jan 2023 14:03:26 +0000 (07:03 -0700)
commite78e14a4a0a0602525a901f4adae8a311270dea2
tree40fd03b19e3dec281f1e6876751cc6076b7089dc
parentaac3c51c551f16687490a0c8e3f2a70357642b74
fix errors handling optional Waypoint fields. (#948)

* fix errors handling optional Waypoint fields.

1. Hide wp_flags from formats by using WAYPT_SET.
2. Don't print values corresponding to Waypoint fields that aren't
valid.
  a) if the field uses wp_flags, then the flag must be set.
  b) power, cadence heartrate must not be zero.

This is in anticipation of use of std::optional instead of wp_flags
to indicate an optional value is present.
The use of invalid power, cadence, and heartrate values was found
fortuitously.

Note this changes kml output, using empty gx:value elements to
correspond to missing data.  gx:value elements are of type
string, the empty string do not violate the schema (unlike empty
when elements).  However, it is unclear who is using this extra
SchemaData so we cannot check to make sure they acutally handle
empty string values.

* don't use WAYPT_HAS with wp_flags that aren't optionals.

* fix some bugs with our home grown optionals.

mostly not using WAYPT_SET resulting in the value being lost.
12 files changed:
defs.h
dg-100.cc
garmin.cc
garmin_fit.h
globalsat_sport.cc
kml.cc
qstarz_bl_1000.cc
reference/realtime.kml
reference/track/gpx_garmin_extensions-kml_track.kml
reference/track/gtrnctr_power-kml.kml
v900.cc
xcsv.cc